package com.lcf.system.controller;


import cn.dev33.satoken.annotation.SaCheckPermission;
import com.lcf.framework.utils.UserUtils;
import com.lcf.framework.vo.PageVO;
import com.lcf.system.query.MovieCollectPageQuery;
import com.lcf.system.service.MovieCollectService;
import com.lcf.system.vo.MovieCollectVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * 收藏(MovieCollect)表控制层
 *
 * @author lcf
 * @since 2025-05-07 22:23:22
 */
@Tag(name = "收藏")
@RestController
@RequestMapping("movieCollect")
public class MovieCollectController {
    @Resource
    private MovieCollectService movieCollectService;

    /**
     * 收藏记录
     */
    @Operation(summary = "收藏记录")
    @SaCheckPermission("movieCollect:page")
    @GetMapping("page")
    public PageVO<MovieCollectVO> page(MovieCollectPageQuery query) {
        return movieCollectService.page(query);
    }

    /**
     * 我的收藏记录
     */
    @Operation(summary = "我的收藏记录")
    @GetMapping("myPage")
    public PageVO<MovieCollectVO> myPage(MovieCollectPageQuery query) {
        query.setUserId(UserUtils.getUserId());
        return movieCollectService.page(query);
    }

    /**
     * 收藏
     */
    @Operation(summary = "收藏")
    @PostMapping("collect/{movieId}")
    public void collect(@PathVariable @Schema(description = "电影ID") long movieId) {
        movieCollectService.collect(movieId);
    }

    /**
     * 取消收藏
     */
    @Operation(summary = "取消收藏")
    @PostMapping("cancelCollect/{movieId}")
    public void cancelCollect(@PathVariable @Schema(description = "电影ID") long movieId) {
        movieCollectService.cancelCollect(movieId);
    }
}

